<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
abstract class DSConnector {
	
	/**
	 * Enter description here ...
	 */
	abstract protected function fetch();
	
	/**
	 * Enter description here ...
	 */
	abstract protected function add();
	
	/**
	 * Enter description here ...
	 */
	abstract protected function update();
	
	/**
	 * Enter description here ...
	 */
	abstract protected function remove();
	
	/**
	 * Enter description here ...
	 */
	abstract protected function getRequestDao();
	
	/**
	 * Renvoie la reponse
	 */
	protected function getResponse() {
		$req = $this->getRequestDao();
		if (isset($req)){
			switch ($req->getOperationType()) {
				case 'add' :
					return $this->add();
				case 'remove' :
					return $this->remove();	
				case 'update' :
					return $this->update();	
				case 'fetch' :
				default :
					return $this->fetch();
			}
		}
	}

	/**
	 * Enter description here ...
	 */
	protected function formatResponse(IDataSetDao $dataSet) {
		return '<pre>'.print_r($dataSet,true).'</pre>';
	}
	
	/**
	 * Enter description here ...
	 */
	final public function response() {
		return $this->formatResponse($this->getResponse()); 
	}
}
?>